import React, {Component} from 'react';
import {StyleSheet, Text, View, TouchableOpacity, Button} from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons';
import Feather from 'react-native-vector-icons/Feather';
import NavigationBar from '../common/NavigationBar';
import NavigationUtil from "../navigator/NavigationUtil";

// 定义主题
const THEME_COLOR = '#678';
export default class MyPage extends Component {

  /**
   * 生成navBar左侧按钮
   * @returns {*}
   */
  getLeftButton() {
    return <View>
      <TouchableOpacity style={{padding: 8, marginLeft: 12}}>
        <Ionicons
          name={'ios-arrow-back'}
          color={'white'}
          size={26}
        />
      </TouchableOpacity>
    </View>
  }

  /**
   * 生成navBar右侧按钮
   * @returns {*}
   */
  getRightButton() {
    return <View style={{flexDirection: 'row', alignItems: 'center'}}>
      <TouchableOpacity
        onPress={() => {
        }}
      >
        <View style={{padding: 5}}>
          <Feather
            name={'share-2'}
            color={'white'}
            size={24}
          />
        </View>
      </TouchableOpacity>
      <TouchableOpacity
        onPress={() => {
        }}
      >
        <View style={{padding: 5, marginRight: 8}}>
          <Feather
            name={'search'}
            color={'white'}
            size={24}
          />
        </View>
      </TouchableOpacity>
    </View>
  }

  render() {
    // 配置状态栏样式
    const statusBar = {
      backgroundColor: THEME_COLOR,
      barStyle: 'light-content'
    };
    return (
      <View style={styles.container}>
        <NavigationBar
          title={'我的'}
          statusBar={statusBar}
          style={{
            backgroundColor: THEME_COLOR
          }}
          leftButton={this.getLeftButton()}
          rightButton={this.getRightButton()}
        />
        <Text style={styles.welcome}>MyPage</Text>
        <Button
          title={'测试Fetch'}
          onPress={() => {
            NavigationUtil.goPage({}, 'FetchDemoPage')
          }}
        />
        <Button
          title={'测试AsyncStorage'}
          onPress={() => {
            NavigationUtil.goPage({}, 'AsyncStorageDemoPage')
          }}
        />
        <Button
          title={'测试DataStore'}
          onPress={() => {
            NavigationUtil.goPage({}, 'DataStoreDemoPage')
          }}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  }
});
